//工具生成，请不要手动修改...
let r: any, StructCoder: any;
/** 传入k-coder来进行初始化 */
export function initXlsx(kcoder: any) {
    r = new kcoder.BinaryReader();
    StructCoder = kcoder.StructCoder;
}

/** 表对象 */
export const Xlsx = {} as IXlsx;
const dataDic: any = {};
const loadedXlsxDic: any = {};
const loadedCfgDic: any = {};
/** 读取表数据 */
export function loadData(buf: Uint8Array) {
    r.start(buf);
    while (r.hasNext) {
        let name = r.str;
        Object.defineProperty(Xlsx, name, { get: r.byte ? () => loadCfg(name) : () => loadXlsx(name), enumerable: true, configurable: true });
        dataDic[name] = r.cut(r.uint);
    }
    for (let name in loadedXlsxDic) loadXlsx(name);
    for (let name in loadedCfgDic) loadCfg(name);
    r.end();
}

function loadVos(name: string) {
    r.start(dataDic[name]);
    delete dataDic[name];
    let struct: any = [];
    let len = r.uint;
    while (len--) struct.push([r.str, r.uint, r.uint, r.uint]);
    let coder = new StructCoder(struct);
    let vos: any = [];
    while (r.hasNext) vos.push(coder.decode(r));
    return vos;
}

function loadXlsx(name: string) {
    let vos = loadVos(name);
    let id2vo: any = {};
    for (let vo of vos) id2vo[vo.id] = vo;
    return loadedXlsxDic[name] = Object.defineProperty(Xlsx, name, { value: { vos, count: vos.lengt, get: (id: number) => id2vo[id] } })[name];
}

function loadCfg(name: string) {
    return loadedCfgDic[name] = Object.defineProperty(Xlsx, name, { value: loadVos(name)[0] })[name];
}

interface Xlsx<T> {
    readonly vos: T[];
    readonly count: number;
    get: (id: string | number) => T;
}

interface IXlsx {
    /** [test.xlsx] */
    readonly test: Xlsx<XlsxVo.Test>;
    /** [test/test2.xlsx] */
    readonly test2: Xlsx<XlsxVo.Test2>;
    /** [testCfg.xlsx] */
    readonly testCfg: XlsxVo.TestCfg;
}

/** 表vo结构 */
export namespace XlsxVo {

    /** [test.xlsx] */
    export interface Test {
        /** 唯一ID */
        readonly id: number
        /** 唯一字段 */
        readonly field: string
        /** 字符串 */
        readonly str: string
        /** 正整形 */
        readonly num: number
        /** 整形 */
        readonly num1: number
        /** 浮点型 */
        readonly num2: number
        /** 整形数组 */
        readonly num3: number[]
    }

    /** [test/test2.xlsx] */
    export interface Test2 {
        /** 唯一ID */
        readonly id: number
        /** 唯一字段 */
        readonly field: string
        /** 字符串 */
        readonly str: string
        /** 正整形 */
        readonly num: number
        /** 整形 */
        readonly num1: number
        /** 浮点型 */
        readonly num2: number
        /** 整形数组 */
        readonly num3: number[]
    }

    /** [testCfg.xlsx] */
    export interface TestCfg {
        /** 字符串 */
        readonly test: string
        /** 正整形 */
        readonly num: number
    }

}
/** 表自动生成的杂项代码 */
export namespace XlsxMisc {

    const _Test2Map = {
        /** test */
        test: 1,
        /** test2 */
        test2: 2,
    }
    /** map映射[test/test2.xlsx] */
    export const Test2Map:Readonly<typeof _Test2Map> = _Test2Map

    /** enum映射[test/test2.xlsx] */
    export enum Test2Enum {
        /** test */
        test = 1,
        /** test2 */
        test2 = 2,
    }

    /** const enum映射[test/test2.xlsx] */
    export const enum Test2ConstEnum {
        /** test */
        test = 1,
        /** test2 */
        test2 = 2,
    }

    const _TestMap = {
        /** test */
        test: 1,
        /** test2 */
        test2: 2,
    }
    /** map映射[test.xlsx] */
    export const TestMap:Readonly<typeof _TestMap> = _TestMap

    /** enum映射[test.xlsx] */
    export enum TestEnum {
        /** test */
        test = 1,
        /** test2 */
        test2 = 2,
    }

    /** const enum映射[test.xlsx] */
    export const enum TestConstEnum {
        /** test */
        test = 1,
        /** test2 */
        test2 = 2,
    }

}